package cn.kzgg.ymcc.web.controller;

import cn.kzgg.ymcc.dto.RegisterDto;
import cn.kzgg.ymcc.result.JSONResult;
import cn.kzgg.ymcc.service.IRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
@ControllerAdvice

public class RegisterController {

    @Autowired
    private IRegisterService registerService;

    /**
     * 图形验证码
     * @param key
     * @return
     */
    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult imageCode(@PathVariable("imageCodeKey") String key ){
        String  base64Str=registerService.imageCode(key);
        return JSONResult.show().setData(base64Str);
    }


    /**
     * 短信验证码
     * @param mobile
     * @return
     */
    @GetMapping("/sendSmsCode/{mobile}")
    public JSONResult sendSmsCode(@PathVariable("mobile") String mobile, RegisterDto registerDto ){
        registerService.sendSmsCode(mobile,registerDto);
            return JSONResult.success("成功");
    }
}
